<route lang="json5" type="page">
{
    layout: "default",
    style: {
        navigationBarTitleText: "攻略",
    },
}
</route>

<template>
    <view class="m-base-box m-strategy">
        <view>
            <scroll-view :scroll-top="scrollTop" :scroll-y="true" class="scroll-Y" @scrolltolower="loadMore">
                <view> <strategyItem :columns="list"></strategyItem> </view>
                <wd-loadmore custom-class="loadmore" :state="loading" :finished-text="finishedText" />
            </scroll-view>
        </view>
    </view>
</template>

<script lang="ts" setup>
import { pageUsingGet2 } from "@/service/app";
import strategyItem from "@/components/strategyItem.vue";
const scrollTop = ref(0);
function loadMore() {
    if (noLoading.value) return; // 如果数据全部加载完成了，就不再加载更多
    queryParams.value.current += 1;
    getList();
}
const queryParams = ref({
    current: 1,
    size: 10,
});
const list = ref<any>([]);
const total = ref(0);
const loading = ref<any>("loading");
const finishedText = ref("加载完成");
const noLoading = ref(false); // 数据是否全部加载完成了
function getList() {
    loading.value = "loading";
    pageUsingGet2({ params: queryParams.value }).then((res) => {
        loading.value = "finished";
        console.log("pageUsingGet1", res);
        total.value = res?.data?.total;
        if (res?.data?.records && res?.data?.records.length > 0) {
            list.value = list.value.concat(res?.data?.records);
        }
        if (total.value == list.value.length) {
            finishedText.value = "没有更多数据了";
            noLoading.value = true;
        }
    });
}
function detail(id: string) {
    uni.navigateTo({ url: `/pages/heritage/detail?id=${id}` });
}
onLoad(() => {
    getList();
});
onShareTimeline(() => {
    return {};
});
</script>

<style lang="scss" scoped>
.m-strategy {
    padding: 40rpx 20rpx;
}
</style>
